package com.ruoyi.decision.service.impl;

import com.ruoyi.decision.domain.Strategy;
import com.ruoyi.decision.mapper.StrategyMapper;
import com.ruoyi.decision.service.IStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Locale;
import java.util.UUID;

/**
 * 优化策略Service业务层处理
 * 
 * @author zbw
 * @date 2022-07-20
 */
@Service
public class StrategyServiceImpl implements IStrategyService 
{
    @Autowired
    private StrategyMapper strategyMapper;

    /**
     * 查询优化策略
     * 
     * @param strategyId 优化策略主键
     * @return 优化策略
     */
    @Override
    public Strategy selectStrategyByStrategyId(String strategyId)
    {
        return strategyMapper.selectStrategyByStrategyId(strategyId);
    }

    /**
     * 查询优化策略列表
     * 
     * @param strategy 优化策略
     * @return 优化策略
     */
    @Override
    public List<Strategy> selectStrategyList(Strategy strategy)
    {
        return strategyMapper.selectStrategyList(strategy);
    }

    /**
     * 新增优化策略
     * 
     * @param strategy 优化策略
     * @return 结果
     */
    @Override
    public int insertStrategy(Strategy strategy)
    {
        String strategyId = UUID.randomUUID().toString().toLowerCase(Locale.ROOT).replace("-","");
        strategy.setStrategyId(strategyId);
        return strategyMapper.insertStrategy(strategy);
    }

    /**
     * 修改优化策略
     * 
     * @param strategy 优化策略
     * @return 结果
     */
    @Override
    public int updateStrategy(Strategy strategy)
    {
        return strategyMapper.updateStrategy(strategy);
    }

    /**
     * 批量删除优化策略
     * 
     * @param strategyIds 需要删除的优化策略主键
     * @return 结果
     */
    @Override
    public int deleteStrategyByStrategyIds(String[] strategyIds)
    {
        return strategyMapper.deleteStrategyByStrategyIds(strategyIds);
    }

    /**
     * 删除优化策略信息
     * 
     * @param strategyId 优化策略主键
     * @return 结果
     */
    @Override
    public int deleteStrategyByStrategyId(String strategyId)
    {
        return strategyMapper.deleteStrategyByStrategyId(strategyId);
    }
}
